﻿Imports FinanceiroDAL
Public Class itensCaixaBLL
    Dim objDal As New itensCaixaDAL
#Region "Propriedades"
    Property codigo As Integer
    Property itecvalor As Decimal
    Property itecdata As Date
    Property operacao As Integer 'status
#End Region
#Region "Construtores"
    Sub New()
    End Sub
    Sub New(ByVal codigo As Integer)
        carrega(codigo)
    End Sub
    Sub New(ByVal cod As Integer, ByVal itensval As Decimal, ByVal itdata As Date, ByVal op As Integer)
        Me.codigo = cod
        Me.itecvalor = itensval
        Me.itecdata = itdata
        Me.operacao = op
    End Sub
#End Region
#Region "Metodos"
    Sub carrega(ByVal codigo As Integer)
        Dim tab As DataTable
        Try
            objDal = New itensCaixaDAL
            tab = objDal.localiza_itens(codigo)
            If (tab.Rows.Count > 0) Then
                Me.codigo = tab.Rows(0).Item("cai_codigo").ToString
                Me.itecvalor = tab.Rows(0).Item("itec_valor").ToString
                Me.itecdata = tab.Rows(0).Item("itec_data").ToString
                Me.operacao = tab.Rows(0).Item("sta_codigo").ToString
            End If
        Catch ex As Exception
            Throw ex
        Finally
            objDal = Nothing
        End Try
    End Sub
    Sub limpar()
        Me.codigo = Nothing
        Me.itecvalor = Nothing
        Me.itecdata = Nothing
        Me.operacao = Nothing
    End Sub
#End Region
#Region "Funções"
    Public Function inserir() As Boolean
        Dim retorno As Boolean
        Try
            objDal = New itensCaixaDAL
            objDal.inserir(Me.codigo, Me.itecvalor, Me.itecdata, Me.operacao)
            retorno = True
        Catch ex As Exception
            retorno = False
            Throw ex
        Finally
            objDal = Nothing
        End Try
        Return retorno
    End Function
    Public Function localTodos() As DataTable
        Dim tab As DataTable
        Try
            objDal = New itensCaixaDAL
            tab = objDal.localTodos(Me.codigo)
        Catch ex As Exception
            Throw ex
        Finally
            objDal = Nothing
        End Try
        Return tab
    End Function
#End Region
End Class
